import Axios from "./../utils/axios";
import api from "@/api";

function UserLogin(username, password) {
  return Axios.post(api.permission.UserLogin, {
    username,
    password,
  });
}

function GetMenu() {
  return Axios.get(api.permission.GetMenu, {});
}

function RoleList() {
  return Axios.get(api.permission.RoleList, {});
}

function AddRole(data) {
  console.log(data);
  return Axios.post(api.permission.AddRole, data);
}

function UpdateRole(data) {
  console.log(data);
  return Axios.post(api.permission.UpdateRole, data);
}

function GetRole(id) {
  console.log(id);
  return Axios.get(api.permission.GetRole + `/${id}`);
}

function DelRole(idArr) {
  console.log(idArr);
  return Axios.post(api.permission.DelRole, {
    idList: idArr,
  });
}

function UpdateRoles(data) {
  console.log(data);
  return Axios.post(api.permission.UpdateRoles, data);
}

function MemberList(data) {
  return Axios.post(api.permission.MemberList, data);
}

function AddMember(data) {
  console.log(data);
  return Axios.post(api.permission.AddMember, data);
}

function Register(data) {
  return Axios.post(api.permission.Register, data);
}

function UpdateMember(data) {
  console.log(data);
  return Axios.post(api.permission.UpdateMember, data);
}

function DelMember(data) {
  console.log(data);
  return Axios.post(api.permission.DelMember, data);
}

function GetUserById(id) {
  console.log(id);
  return Axios.get(api.permission.GetUserById, { params: id });
}

function DelMemberRole(data) {
  return Axios.post(api.permission.DelMemberRole, data);
}

function OperateLogList(data) {
  return Axios.post(api.permission.OperateLogList, data);
}

function GetUserRoles(id) {
  console.log(id);
  return Axios.post(api.permission.GetUserRoles + `/${id}`);
}

function SetUserRoles(data) {
  return Axios.post(api.permission.SetUserRoles, data);
}

function DelOperationLog(data) {
  return Axios.post(api.permission.DelOperationLog, data);
}
export default {
  UserLogin,
  Register,
  RoleList,
  AddRole,
  UpdateRole,
  GetRole,
  DelRole,
  UpdateRoles,
  GetMenu,
  MemberList,
  AddMember,
  UpdateMember,
  DelMember,
  GetUserById,
  DelMemberRole,
  OperateLogList,
  GetUserRoles,
  SetUserRoles,
  DelOperationLog,
};
